const getters = {
	sidebar: (state) => state.app.sidebar,
	second: (state) => state.app.second,
	size: (state) => state.app.size,
	userId: (state) => state.user.userId,
	tenantId: (state) => state.user.tenantId,
	device: (state) => state.app.device,
	visitedViews: (state) => state.tagsView.visitedViews,
	cachedViews: (state) => state.tagsView.cachedViews,
	token: (state) => state.user.token,
	avatar: (state) => state.user.avatar,
	info: (state) => state.user.info,
	name: (state) => state.user.name,
	kfInfo: (state) => state.user.kfInfo,
	introduction: (state) => state.user.introduction,
	roles: (state) => state.user.roles,
	permissions: (state) => state.user.permissions,
	findInfo: (state) => state.permission.findInfo,
	permission_routes: (state) => state.permission.routes,
	sidebarRouters: (state) => state.permission.sidebarRouters,
	emojis: (state) => state.chat.emojis,
	unreadMessage: (state) => state.ws.unreadMessage,
	searchedChatlist(state) {
		return state.chat.chatlist.filter((sessions) => {
			if (!sessions.user.name) {
				return true;
			} else {
				return sessions.user.name.includes(state.chat.searchText);
			}
		});
	},
	// 通过当前选择是哪个对话匹配相应的对话
	selectedChat(state) {
		return state.chat.chatlist.find((session) => session.id === state.chat.selectId);
	},
	messages(state) {
		return state.chat.messages
			.map((item) => ({
				...item,
				index: state.chat.messages.length + 1,
			}))
			.filter((item) => {
				if (item.userId === '0') {
					return true;
				}
				return (+item.userId === +state.chat.selectId && +item.joinUserId === state.user.userId) || (+item.joinUserId === +state.chat.selectId && +item.userId === state.user.userId);
			});
	},
	selectId(state) {
		return state.chat.selectId;
	},
	sendIndex: (state) => state.ws.sendIndex,
	pages: (state) => state.chat.pages,
};
export default getters;
